import {
  exportUrl,
  getAreaCodeList,
  getOrderTypeList,
  getAccountingFlagList,
  getCurrentWarehouseCode,
  getLocationCodeList
} from "@/api/outbound/wmsOutTaskDetail"
import {
  getPushStatus,
  getLineStatus,
  getSnControl,
} from "@/api/inbound/mesInTaskDetail";
// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl
    //auth: "auth:operlog:export", //权限字段
  },
  {
    name: $i18n.t("wmsOutTaskDetail.button1"), //加入合单计划
    type: "primary",
    icon: "el-icon-circle-plus-outline",
    handleName: "mergeOrder", //点击时返回的标识
    isMultiple: true,
    // auth: "wms:wmsOutTaskDetail:mergeOrder", //权限字段
    disabled: (data) => data.length == 0,
  },
  {
    name: $i18n.t("wmsOutTaskDetail.button2"), //取消合单
    type: "primary",
    icon: "el-icon-circle-plus-outline",
    handleName: "cancelJoin", //点击时返回的标识
    isMultiple: true,
    // auth: "wms:wmsOutTaskDetail:mergeOrder", //权限字段
  },
  // {
  //     name: $i18n.t('common.add'),
  //     type: "primary",
  //     icon: "el-icon-circle-plus-outline",
  //     handleName: 'add', // 点击时返回的标识
  //     // auth: "auth:user:add", //权限字段
  // },
  // {
  //     name: $i18n.t('common.delete'),
  //     type: 'danger',
  //     icon: 'el-icon-delete',
  //     handleName: 'delete',
  //     isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  //     // auth: "auth:user:delete", //权限字段
  // }
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.view"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "show" //点击时返回的标识
  },
  {
    name: $i18n.t("common.edit"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "edit" //点击时返回的标识
  }
]
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    warehouseCode: {
      type: "select",
      label: $i18n.t("common.warehouse"),
      prop: {
        value: "modelingCode",
        text: "modelingName"
      },
      options: async (data) => {
        const res = await getCurrentWarehouseCode();
        let list = res.data.result || []
        list.forEach(val => {
          val.modelingName = `${val.modelingCode}-${val.modelingName}`
        });
        return list;
      },
    },
    orderNo: {
      type: "input",
      label: $i18n.t("wmsOutTaskDetail.orderNo")
    },
    goodsCode: {
      type: "input",
      label: $i18n.t("common.materialCode")
    },
    goodsName: {
      type: "input",
      label: $i18n.t("common.materialName")
    },
    batchNo: {
      type: "input",
      label: $i18n.t("common.batchNo")
    },
    version: {
      type: "input",
      label: $i18n.t("common.version")
    },
    orderType: {
      type: "select",
      label: $i18n.t("wmsOutTaskDetail.orderType"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getOrderTypeList()
        return list.data.result
      }
    },
    lineStatus: {
      type: "select",
      label: $i18n.t("wmsOutTaskDetail.lineStatus"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getLineStatus()
        return list.data.result
      }
    },
    snControl: {
      type: "select",
      label: $i18n.t("wmsOutTaskDetail.snControl"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getSnControl()
        return list.data.result
      }
    },
    erpStatus: {
      type: "select",
      label: $i18n.t("wmsOutTaskDetail.pushStatus"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getPushStatus()
        return list.data.result
      }
    },
    orderLine: {
      type: "input",
      label: $i18n.t("wmsOutTaskDetail.orderLine2")
    },
    upstreamOrderLine: {
      type: "input",
      label: $i18n.t("wmsOutTaskDetail.upstreamOrderLine")
    },
  }
}
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: true,
  isShowSubmitBtn: false,
  formDesc: {
    areaCode: {
      type: "select",
      label: $i18n.t("common.areaCode"),
      layout: 12,
      required: false,
      prop: {
        value: "areaCode",
        text: "areaDesc"
      },
      options: async (data) => {
        const list = await getAreaCodeList()
        return list.data.result
      }
    },
    locationCode: {
      type: "input",
      label: $i18n.t("common.locationCode"),
      layout: 12,
      required: false
    },
    orderNo: {
      type: "input",
      label: $i18n.t("wmsOutTaskDetail.orderNo"),
      layout: 12,
      required: false
    },
    orderLine: {
      type: "input",
      label: $i18n.t("wmsOutTaskDetail.orderLine"),
      layout: 12,
      required: false
    },
    orderType: {
      type: "select",
      label: $i18n.t("wmsOutTaskDetail.orderType"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getOrderTypeList()
        return list.data.result
      }
    },
    palletCode: {
      type: "input",
      label: $i18n.t("common.palletCode"),
      layout: 12,
      required: false
    },
    packageCode: {
      type: "input",
      label: $i18n.t("common.packageCode"),
      layout: 12,
      required: false
    },
    boxCode: {
      type: "input",
      label: $i18n.t("common.boxCode"),
      layout: 12,
      required: false
    },
    barcode: {
      type: "input",
      label: $i18n.t("common.uniqueCode"),
      layout: 12,
      required: false
    },
    goodsCode: {
      type: "input",
      label: $i18n.t("common.materialCode"),
      layout: 12,
      required: false
    },
    goodsName: {
      type: "input",
      label: $i18n.t("common.materialName"),
      layout: 12,
      required: false
    },
    amount: {
      type: "number",
      label: $i18n.t("wmsOutTaskDetail.amount"),
      layout: 12,
      required: false
    },
    unit: {
      type: "input",
      label: $i18n.t("common.unit"),
      layout: 12,
      required: false
    },
    customerCode: {
      type: "input",
      label: $i18n.t("wmsOutTaskDetail.customerCode"),
      layout: 12,
      required: false
    },
    owner: {
      type: "input",
      label: $i18n.t("common.owner"),
      layout: 12,
      required: false
    },
    version: {
      type: "input",
      label: $i18n.t("common.version"),
      layout: 12,
      required: false
    },
    accountingFlag: {
      type: "select",
      label: $i18n.t("wmsOutTaskDetail.accountingFlag"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getAccountingFlagList()
        return list.data.result
      }
    },
    accountingTime: {
      type: "datetime",
      label: $i18n.t("wmsOutTaskDetail.accountingTime"),
      layout: 12,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss"
      }
    },
    accountingOrder: {
      type: "input",
      label: $i18n.t("wmsOutTaskDetail.accountingOrder"),
      layout: 12,
      required: false
    },
    accountingMessage: {
      type: "input",
      label: $i18n.t("wmsOutTaskDetail.accountingMessage"),
      layout: 12,
      required: false
    },
    remark: {
      type: "input",
      label: $i18n.t("wmsOutTaskDetail.remark"),
      layout: 12,
      required: false
    }
  }
}
